<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
      box-sizing: border-box;
    }

    ul {
      border: 1px solid red;
    }

    ul li {
      margin: 15px 0;
      border: 1px solid black;
      cursor: pointer;
      font-size: 28px;
    }

    .liback {
      background-color: hotpink;
    }
  </style>
</head>

<body>
  <ul>
    <li>我就是好人的了</li>
    <li>你自己没看错了吧</li>
    <li>他所不知道了</li>
  </ul>
</body>
<script>
  document.querySelectorAll("ul li").forEach((items, index, Array) => {
    items.addEventListener("click", (e) => {
      e.currentTarget.classList.toggle("liback");
    });
  });
</script>

</html>